/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
typedef struct ListNode ListNode;
struct ListNode *detectCycle(struct ListNode *head) {
    ListNode* less=head;
    ListNode* fast=head;
    while(fast && fast->next)
    {
        less=less->next;
        fast=fast->next->next;
        if(fast==less)
        {
            ListNode* mid=fast;
            ListNode* pcur=head;
            while(pcur!=mid)
            {
                pcur=pcur->next;
                mid=mid->next;
            }
            return pcur;
        }
    }
    //链表不带环
    return NULL;
}